using System;
using System.Collections.Generic;
using System.Text;
using DAP;
using Dominio;
using Services;

namespace Presenters
{
    public class BugDestailsPresenter
    {
        private BugRepository repository;
        private ReleaseRepository releaseRepository;
        private TesterRepository testerRepository;
        private MailService mailService;

        public BugDestailsPresenter()
        {
            repository = new BugRepository();
            testerRepository = new TesterRepository();
            releaseRepository = new ReleaseRepository();
            mailService = new MailService();
        }

        public Bug getBugById(int Id)
        {
            return repository.getBugById(Id);
        }

        public void UpdateBug(int id, String description, String so, String soVersion, String type, int releaseId, String bugstatus, int tester)
        {
            Release release = releaseRepository.getReleaseById(releaseId);
            release.getMaturity();
            Bug bug = new Bug(id, description, so, soVersion, type, release, bugstatus, testerRepository.getUserById(tester));
            repository.UpdateBug(bug);
        }

        public void SaveBug(String description, String so, String soVersion, String type, int releaseId, int tester)
        {
            Release release = releaseRepository.getReleaseById(releaseId);
            release.getMaturity();
            Bug bug = new Bug(description, so, soVersion, type, release, testerRepository.getUserById(tester));
            repository.SaveBug(bug);
            mailService.sendMail(MailTypeEnum.newBug.ToString(), release.Tm.Email);
        }

    }
}
